/*
 * GikoletMIDlet.java
 *
 * Created on 2008/07/05 +0900
 *
 * $Revision: 33 $
 * $Date: 2008-07-27 15:31:44 +0000 (Sun, 27 Jul 2008) $
 */

package org.gikolet.platform.midp;

import java.util.Vector;

import org.gikolet.bbs.ui.Gikolet;
import org.gikolet.bbs.ui.GikoletExtensions;
import org.gikolet.framework.application.ApplicationLifecycle;
import org.gikolet.framework.inject.AbstractSingletonProvider;
import org.gikolet.framework.inject.Binder;
import org.gikolet.framework.inject.Provider;
import org.gikolet.framework.inject.Scope;
import org.gikolet.framework.inject.Serviceable;
import org.gikolet.framework.platform.midp.ApplicationMIDlet;

/**
 * @author Tetsutaro (latest modification by $Author: tetsutaro.ss $)
 * @version $Revision: 33 $ $Date: 2008-07-27 15:31:44 +0000 (Sun, 27 Jul 2008) $
 */
public class GikoletMIDlet extends ApplicationMIDlet {
    public void configure(Binder binder) {
	super.configure(binder);

	String severPropertyKey = "iMona-ServerURI-";
	Vector vs = new Vector();
	String server = null;
	int i = 1;
	do {
	    server = getAppProperty(severPropertyKey + i++);
	    if (server != null) {
		vs.addElement(server);
	    }
	} while (server != null);

	final String[] severs = new String[vs.size()];
	vs.copyInto(severs);

	Provider gikoletProvider = new AbstractSingletonProvider() {
	    protected Object createInstance() {
		return new Gikolet(severs);
	    }
	};
	binder.bind(Gikolet.class).toProvider(gikoletProvider);
	binder.bind(Serviceable.class).toProvider(gikoletProvider);
	binder.bind(ApplicationLifecycle.class).toProvider(gikoletProvider);
	binder.bind(GikoletExtensions.class).to(MIDPGikoletExtensions.class)
		.in(Scope.SINGLETON);
    }
}
